<template>
  <view class="index">
    <view class="jtop">
      <view class="status_bar"><!-- 这里是状态栏 --></view>
      <view class="jtop_l" @tap="navigateBack"
        ><image src="../../static/img/ic_back.png"></image
      ></view>
      <view class="jtop_c">隐私</view>
    </view>
    <view class="tophr"></view>

    <view class="ubs">
      <view class="ub">
        <view class="ub_l">加我为联系人时需要验证</view>
        <switch
          :checked="switch1"
          @change="switch1Change"
          style="transform:scale(0.7)"
          color="#4CD964"
          class="fr"
        />
      </view>
    </view>

    <view class="ubs">
      <view class="ub">
        <view class="ub_l">允许别人找到我</view>
        <switch
          :checked="switch2"
          @change="switch2Change"
          style="transform:scale(0.7)"
          color="#4CD964"
          class="fr"
        />
      </view>
    </view>

    <view class="js">
      开启后，别人可通过手机或邮箱搜索到当前企业身份
    </view>

    <view class="ubs">
      <view class="ub">
        <view class="ub_l">可通过个人名片添加我</view>
        <switch
          :checked="switch3"
          @change="switch3Change"
          style="transform:scale(0.7)"
          color="#4CD964"
          class="fr"
        />
      </view>
    </view>

    <view class="ubs">
      <view class="ub">
        <view class="ub_l">获取我的微信好友关系</view>
        <switch
          :checked="switch4"
          @change="switch4Change"
          style="transform:scale(0.7)"
          color="#4CD964"
          class="fr"
        />
      </view>
      <view class="ub">
        <view class="ub_l">向我推荐新的客户</view>
        <switch
          :checked="switch5"
          @change="switch5Change"
          style="transform:scale(0.7)"
          color="#4CD964"
          class="fr"
        />
      </view>
    </view>

    <view class="js">
      开启后，会向你推荐手机通讯录中的外部联系人
    </view>
  </view>
</template>

<script>
import request from '@/common/request.js';
export default {
  data() {
    return {
      switch1: true,
      switch2: true,
      switch3: true,
      switch4: true,
      switch5: true,
    };
  },
  methods: {
    // 点击切换
    switch1Change: function(e) {
      this.switch1 = e.target.value;
      this.gh('w1', e.target.value);
    },
    switch2Change: function(e) {
      this.switch2 = e.target.value;
      this.gh('w2', e.target.value);
    },
    switch3Change: function(e) {
      this.switch3 = e.target.value;
      this.gh('w3', e.target.value);
    },
    switch4Change: function(e) {
      this.switch4 = e.target.value;
      this.gh('w4', e.target.value);
    },
    switch5Change: function(e) {
      this.switch5 = e.target.value;
      this.gh('w5', e.target.value);
    },

    // 调用后台接口修改内容
    gh(a, b) {
      request({
        url: '/ucenter/user/gender?gender=' + a,
        // data: {
        // 	gender: a
        // },

        method: 'PUT',
        success: openIdRes => {
          console.log(openIdRes);
          // 已经授权了、查询到用户的数据了
          if (openIdRes.data.success == true) {
            this.repeat_click = true;
            uni.showToast({
              title: '修改成功',
            });
          } else {
            // 错误
            this.repeat_click = true;
            uni.showToast({
              title: openIdRes.data.msg,
              icon: 'none',
            });
            this.isLoading = false;
          }
        },
        fail: () => {
          this.repeat_click = true;
          uni.showToast({
            title: '服务器开小差，请稍后~',
            icon: 'none',
          });
          return false;
        },
      });
    },

    bindLogin() {
      uni.navigateTo({
        url: '../login/login',
      });
    },
    navigateBack() {
      uni.navigateBack();
    },
  },
};
</script>

<style>
.ubs {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  margin: 20rpx 0 0 0;
  border: 1px solid #dddddd;
  border-left: 0;
  border-right: 0;
  background: #ffffff;
}
.ub {
  width: 720rpx;
  height: 90rpx;
  display: block;
  float: right;
  line-height: 90rpx;
  border-bottom: 1px solid #dddddd;
}
.ubs .ub:last-child {
  border: 0;
}
.ub_l {
  width: auto;
  height: auto;
  display: block;
  float: left;
  font-size: 34rpx;
  line-height: 90rpx;
  color: #000000;
  margin: 0rpx 0 0 0;
}
.ub_jt {
  width: 16rpx;
  height: 25rpx;
  display: block;
  float: right;
  margin: 32rpx 30rpx 0 0;
}
.ub_t {
  width: auto;
  height: 40rpx;
  display: block;
  float: right;
  font-size: 32rpx;
  line-height: 40rpx;
  text-align: right;
  color: #999999;
  margin: 25rpx 20rpx 0 0;
}
.ub_t image {
  width: 36rpx;
  height: 36rpx;
  display: block;
  float: right;
  margin: 0rpx 0rpx 0 6rpx;
}
.ub_tx {
  width: 114rpx;
  height: 114rpx;
  display: block;
  float: right;
  margin: 30rpx 20rpx 30rpx 0;
  border-radius: 8rpx;
}
.uba {
  height: auto;
}
.uba .ub_l {
  margin-top: 45rpx;
}
.uba .ub_jt {
  margin-top: 75rpx;
}
.ubscc {
  text-align: center;
  line-height: 90rpx;
  color: #eb5342;
  font-size: 32rpx;
}
.js {
  width: 720rpx;
  height: auto;
  display: block;
  float: right;
  margin: 25rpx 0 10rpx;
  font-size: 28rpx;
  line-height: 36rpx;
  color: #888888;
}

.index {
  background: rgb(242, 242, 242);
  width: 100%;
  height: auto;
}
.jtop {
  width: 100%;
  height: 88rpx;
  background: #ffffff;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  box-shadow: inset 0px -1px 0px #dddddd;
}
.jtop_l {
  width: auto;
  height: 88rpx;
  display: block;
  float: left;
  font-size: 32rpx;
  color: #000000;
  line-height: 88rpx;
  margin: 0 0 0 30rpx;
}
.jtop_l image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
  margin: 20rpx 0 20rpx 0;
}
.jtop_lt {
  margin: 0 0 0 10rpx;
}
.jtop_r {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: right;
  margin: 20rpx 20rpx 0 0;
}
.jtop_rl {
  margin: 20rpx 30rpx 0 0;
}
.jtop_r image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
}
.jtop_c {
  width: 70%;
  height: 48rpx;
  line-height: 48rpx;
  display: block;
  float: left;
  position: fixed;
  top: 20rpx;
  left: 15%;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
}
.jtop_c image {
  width: 36rpx;
  height: 36rpx;
  display: inline-block;
  float: none;
  margin-bottom: -5rpx;
  margin-left: 5rpx;
}
.jtop_b {
  width: 100%;
  height: auto;
  background: #ffffff;
  position: fixed;
  top: 88rpx;
  left: 0;
  z-index: 1001;
}
.tophr {
  width: 100%;
  height: 88rpx;
}
</style>
